-- time_bomb
-- create by dengc
-- 技能：定时炸弹爆炸
-- time_bomb(100,10): 造成100 + 10 * floor 点伤害

return {
    apply = function(source, target, skillId, round, para, extra)
        -- 获取不到玩家对象
        if target.type ~= OBJECT_TYPE_USER then
            return;
        end

        local floor = DungeonM.currentLayer();
        local damage = para[1] + para[2] * floor;

        -- 对玩家造成伤害
        CombatM.doDamage(target, target, damage, skillId);

        -- 翻开所有石板，打击怪物，并摧毁场上的阿瓦隆巨炮
        local monster;
        local grid;
        for pos = 1, GRID_SIZE do
            grid = DungeonM.getGridByPos(pos);
            if not grid:isOpened() then
                grid:open();
            end

            monster = grid.monster;
            if monster and not monster:isDead() then
                -- 对怪物造成伤害
                CombatM.doDamage(monster, monster, damage, skillId);
            end
        end

        -- 玩家出手事件
        EventMgr.fire(event.PLAYER_MOVE);
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), tonumber(arr[2]) };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        return desc;
    end,
};
